import request from '@/utils/request'

// 管理员查询文章管理列表
export function listArticles(query) {
    return request({
        url: '/articles/articles/listAll',
        method: 'get',
        params: query
    })
}

// 自己查询文章管理列表
export function listMyArticles(query) {
    return request({
        url: '/articles/articles/list',
        method: 'get',
        params: query
    })
}

// 查询文章管理详细
export function getArticles(articleId) {
    return request({
        url: '/articles/articles/' + articleId,
        method: 'get'
    })
}

// 新增文章管理
export function addArticles(data) {
    return request({
        url: '/articles/articles',
        method: 'post',
        data: data
    })
}

// 修改文章管理
export function updateArticles(data) {
    return request({
        url: '/articles/articles',
        method: 'put',
        data: data
    })
}

// 删除文章管理
export function delArticles(articleId) {
    return request({
        url: '/articles/articles/' + articleId,
        method: 'delete'
    })
}

/**
 * 修改文章发布状态
 * @param articleId
 * @param isPublish
 * @returns {*}
 */
export function changePublishStatus(articleId, isPublish) {
    return request({
        url: '/articles/articles/changePublishStatus',
        method: 'put',
        data: {
            articleId,
            isPublish,
        }
    })
}

/**
 * 查询待审核文章列表
 * @returns {*}
 */
export function getReviewArticles() {
    return request({
        url: '/articles/articles/getReviewArticles',
        method: 'get',
    })
}

/**
 * 修改文章审核状态
 * @param articleId
 * @param status
 * @param rejectReason
 * @returns {*}
 */
export function changeArticleStatus(articleId, status, rejectReason) {
    return request({
        url: '/articles/articles/changeArticleStatus',
        method: 'put',
        data: {
            articleId,
            status,
            rejectReason,
        }
    })
}
